package com.faklyn.bootelasticsearch.controller;

import com.faklyn.bootelasticsearch.entity.EsResume;
import com.faklyn.bootelasticsearch.service.EsResumeRepository;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.client.ElasticsearchClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ronghl
 * @date 2021-01-27
 */
@Slf4j
@RestController
public class EsTestController {

    @Resource
    EsResumeRepository esResumeRepository;

    @GetMapping("testEs")
    public Object testEs() {
        return new Object();
    }

    @GetMapping("saveResume")
    public Object saveResume(Long id) {
        EsResume esResume = EsResume.builder().id(id).name("name" + id).sex(id % 2 == 0 ? "女" : "男")
                .createTime(System.currentTimeMillis())
                .country("中国")
                .college("华南农业大学")
                .degree("本科")
                .field("机械自动化设计")
                .description("5年经验，熟悉CAD/soliworker")
                .liveCity("广州")
                .expectedWorkCity("广州,深圳,佛山,东莞,上海,北京,杭州")
                .build();
        EsResume result = esResumeRepository.save(esResume);
        log.info("result={}", result);
        return result;
    }
}
